<?php

namespace App\Repository\Repositories;

use App\Repository\Repositories\Interfaces\OrderProductCommentRepository;
use App\Repository\Models\OrderProductComment;

/**
 * Class OrderProductCommentRepositoryEloquent.
 *
 * @package namespace App\Repository\Repositories;
 */
class OrderProductCommentRepositoryEloquent extends BaseRepository implements OrderProductCommentRepository
{
    /**
     * 搜索
     * @var array
     */
    protected $fieldSearchable = [
        'order_code',
        'orderProduct.product_name',
        'orderProduct.shop_name',
        'user.name',
        'overall',
        'created_at' => 'between',
        'check_status',
    ];

    /**
     * 将前端字段名替换为关联查询模式
     * @var array
     */
    public $fieldSearchReplace = [
        'user_name' => 'user.name',
        'shop_name' => 'orderProduct.shop_name',
        'product_name' => 'orderProduct.product_name'
    ];

    /**
     * 可关联查询的字段
     */
    public $withAllow = [
        'user' => ['id', 'name','pic'],
        'shop' => ['id', 'company_name'],
        'orderProduct',
        'productSku',
    ];

    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return OrderProductComment::class;
    }
}
